<?php

class FP_Validation_StringEquals extends Zend_Validate_Abstract
{

    const NOT_EQUALS = 'stringNotEquals';

    /**
     * Array with message templates
     *
     * @var array
     */
    protected $_messageTemplates = array(
					 self::NOT_EQUALS => "'%value1%' does not match '%value2%'"
					 );

    protected $_messageVariables = array(
					 'value1' => '_value1',
					 'value2' => '_value2'
					 );

    protected $_value1;
    protected $_value2;

    /**
     * Defined by Zend_Validate_Interface
     *
     * Returns true if and only if all the elements of the array argument
     * are equal to one another with string comparison.
     *
     * @param  array $value Value to validate
     * @return boolean
     */
    public function isValid($value)
    {

        $this->_setValue($value);

        $initial = (string) current((array) $value);
        foreach ((array) $value as $element) {
            if ((string) $element !== $initial) {
	      $this->_value1 = $element;
	      $this->_value2 = $initial;
                $this->_error();
                return false;
            }
        }

        return true;
    }

}
